#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>
using namespace std;
class Solution1 {
public:
    int search(vector<int>& nums, int target) {
        int len = nums.size();
        int left = 0, right = len - 1, mid = 0;
        while (left <= right)
        {
            mid = left + (right - left) / 2;
            if (nums[mid] > target)
            {
                right = mid - 1;
            }
            else if (nums[mid] < target)
            {
                left = mid + 1;
            }
            else
            {
                return mid;
            }
        }
        return -1;
    }
};

class Solution2 {
public:
    vector<int> searchRange(vector<int>& nums, int target) {
        if (nums.size() == 0)
        {
            return { -1,-1 };
        }
        int left = 0, right = nums.size() - 1;
        int begin = 0, end = 0;
        while (left < right)
        {
            int mid = left + (right - left) / 2;
            if (nums[mid] < target)
            {
                left = mid + 1;
            }
            else if (nums[mid] >= target)
            {
                right = mid;
            }
        }
        if (nums[left] == target)
        {
            begin = left;
        }
        else {
            return { -1,-1 };
        }
        right = nums.size() - 1;
        while (left < right)
        {
            int mid = left + (right - left + 1) / 2;
            if (nums[mid] <= target)
            {
                left = mid;
            }
            else if (nums[mid] > target)
            {
                right = mid - 1;
            }
        }
        end = right;
        return { begin,end };
    }
};

class Solution {
public:
    int takeAttendance(vector<int>& records) {
        int left = 0, right = records.size() - 1;
        while (left < right)
        {
            int mid = left + (right - left) / 2;
            if (records[mid] == mid)
            {
                left = mid + 1;
            }
            else
            {
                right = mid;
            }
        }
        return records[left] == left ? left + 1 : left;
    }
};

int main()
{

    return 0;
}